//
//  HCFindHeaderButton.m
//  HappyChildren
//
//  Created by WillyZhao on 2016/12/29.
//  Copyright © 2016年 WillyZhao. All rights reserved.
//

#import "HCFindHeaderButton.h"

@implementation HCFindHeaderButton

-(instancetype)initWithFrame:(CGRect)frame andStyle:(HCFindHeaderButtonStyle)style {
    if (self = [super initWithFrame:frame]) {
        [self initSubCustom:style andFrame:frame];
    }
    return self;
}

-(void)initSubCustom:(HCFindHeaderButtonStyle)style andFrame:(CGRect)frame {
    self.style = style;
    
    //提示图片
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(YBKAdaptiveW(30), (frame.size.height - (YBKAdaptiveH(83)/2.0))/2.0, (YBKAdaptiveH(83))/2.0, (YBKAdaptiveH(83))/2.0)];
    imageView.userInteractionEnabled = YES;
    [self addSubview:imageView];
    
    //提示文字
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(imageView.frame.origin.x+imageView.frame.size.width+5, 0, 200, 30)];
    label.font = YBKSystemFont(YBKAdaptiveFont(15));
    label.textColor = [UIColor darkGrayColor];
    label.center = CGPointMake(label.center.x, imageView.center.y);
    [self addSubview:label];
    
    switch (style) {
        case HCFindHeaderButtonMoreStore:
            //更多
        {
            imageView.image = [UIImage imageNamed:@"happy_hotStore"];
            label.text = @"更多信息";
        }
            break;
        case HCFindHeaderButtonHotStore:
            //门店热推
        {
            imageView.image = [UIImage imageNamed:@"happy_findstore"];
            label.text = @"门店热榜";
        }
            break;
        case HCFindHeaderButtonStoreRecom:
            //店家推荐
        {
            imageView.image = [UIImage imageNamed:@"happy_findStar"];
            label.text = @"店家推荐";
        }
            break;
        case HCFindHeaderButtonScoreStore:
            //积分商城
        {
            imageView.image = [UIImage imageNamed:@"happy_find_scoreStore"];
            label.text = @"积分商城";
        }
            break;
        default:
            break;
    }
    
    self.clickBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
    [self addSubview:self.clickBtn];
    [self.clickBtn addTarget:self action:@selector(clickedBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

-(void)clickedBtnAction:(UIButton *)btn {
    if ([self.delegate respondsToSelector:@selector(hcFindHeaderButtonClicked:)]&&self.delegate) {
        [self.delegate hcFindHeaderButtonClicked:self];
    }
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
